package cn.group.hotel2.controller;

import cn.group.hotel2.pojo.dto.FinanceGetCountDTO;
import cn.group.hotel2.pojo.dto.FinancePriceDTO;
import cn.group.hotel2.pojo.dto.FinanceSelectDTO;
import cn.group.hotel2.pojo.vo.FinanceListItemVO;
import cn.group.hotel2.service.IFinanceService;
import cn.group.hotel2.service.IOrderService;
import cn.group.hotel2.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

/**
 * @author : zlh
 * @date : 2022-11-26 10:44
 **/
@RestController
@Slf4j
@RequestMapping("/finance")
@Api(tags = "财务管理模块")
public class FinanceController {

    @Autowired
    IFinanceService financeService;
    @Autowired
    IOrderService orderService;
    public FinanceController() {
        log.debug("创建控制器对象:FinanceController");
    }

    @PostMapping("")
    @ApiOperation("查询财务列表")
    @ApiOperationSupport(order = 400)
    public JsonResult<List<FinanceListItemVO>> list(FinanceSelectDTO financeSelectDTO) throws ParseException {
        log.debug("开始处理【查询财务列表】的请求，参数:页码大小:{},当前页:{},入住时间:{},离开时间:{}",
                financeSelectDTO.getPageSize(),financeSelectDTO.getCurrentPage(),
                financeSelectDTO.getStartTime(),financeSelectDTO.getEndTime());
        List<FinanceListItemVO> list = financeService.list(financeSelectDTO);
        return JsonResult.ok(list);
    }

    @PostMapping("/sumPrice")
    @ApiOperation("查询财务总收入")
    @ApiOperationSupport(order = 402)
    public JsonResult<Double> sumPrice(FinancePriceDTO financePriceDTO) throws ParseException {
        log.debug("开始处理【查询财务总收入】的请求，参数:{}",financePriceDTO);
        Double sumPrice = financeService.selectSumPrice(financePriceDTO);
        return JsonResult.ok(sumPrice);
    }
    @PostMapping("/getCount")
    @ApiOperation("查询订单总数")
    @ApiOperationSupport(order = 401)
    public JsonResult<Integer> getCount(FinanceGetCountDTO financeGetCountDTO) throws ParseException {
        log.debug("开始处理【查询订单总数】的请求，参数:{}",financeGetCountDTO);
        Integer count = financeService.getCount(financeGetCountDTO);
        return JsonResult.ok(count);
    }
}
